<template>
<!-- 跳转到文章详情部分 -->
  <van-cell class="article-item-container" :to="`/article/${article.art_id}`">
    <!-- 标题信息 -->
    <template #title>
      <div class="title van-multi-ellipsis--12">{{ article.title }}</div>
    </template>

    <!-- 底部信息 -->
    <template #label>
      <div v-if="article.cover.type === 3" class="cover-wrap">
        <div
          v-for="(img, index) in article.cover.images"
          :key="index"
          class="cover-item"
        >
          <van-image class="cover_image" fit="cover" :src="img"></van-image>
        </div>
      </div>

      <!-- 底部作者信息 -->
      <div class="label-info-wrap">
        <span>{{ article.aut_name }}</span>
        <span>{{ article.comm_count }}</span>
        <span>{{ article.pubdate | relativeTime }}</span>
      </div>
    </template>

    <!-- 右侧图片信息 只有一张图 显示在右侧 -->
    <template #default v-if="article.cover.type === 1">
      <van-image
        class="right-image"
        fit="cover"
        :src="article.cover.images[0]"
      ></van-image>
    </template>
  </van-cell>
</template>

<script>
export default {
  name: 'ArticleItem',
  props: {
    article: {
      type: Object,
      default: () => ({})
    }
  },
  data () {
    return {

    }
  },
  methods: {

  }
}
</script>

<style lang="less" scoped>
.article-item-container {
  .title {
    font-size: 32px;
    color: #3a3a3a;
  }
  /* 固定右侧盒子 */
  .van-cell__value {
    flex: unset;
    width: 232px;
    height: 146px;
    padding-left: 25px;
    /* 设置图片样式 */
    .right-image {
      width: 100%;
      height: 146px;
    }
  }
  .label-info-wrap {
    span {
      font-size: 22px;
      color: #b4b4b4;
      margin-right: 25px;
    }
  }
  .cover-wrap {
    display: flex;
    padding: 30px 0;
    .cover-item {
      flex: 1;
      height: 146px;

      &:not(:last-child) {
        padding-right: 10px;
      }

      .cover_image {
        width: 100%;
        height: 100%;
      }
    }
  }
}
</style>
